package org.wiw.client.gui;

import org.wiw.client.MarkerPlaceStorage;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.maps.client.MapWidget;
import com.google.gwt.maps.client.control.ControlAnchor;
import com.google.gwt.maps.client.control.ControlPosition;
import com.google.gwt.maps.client.control.Control.CustomControl;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.Widget;

public class MarkersFilterControl extends CustomControl {

	private FilterModel filterModel;

	public MarkersFilterControl(MarkerPlaceStorage storage) {
		super(new ControlPosition(ControlAnchor.TOP_RIGHT, 7, 27));
		filterModel = new FilterModel(storage);
	}

	@Override
	protected Widget initialize(final MapWidget map) {
		Panel container = new FlowPanel();
		Button filterButton = new Button("Filter");
		filterButton.setStyleName("mapControl");
		filterButton.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				FilterDialog dialog = new FilterDialog(filterModel);
				dialog.center();
			}
		});

		container.add(filterButton);
		return container;
	}

	@Override
	public boolean isSelectable() {
		return false;
	}

}
